﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using DataAccessClass;

namespace ProducerBO
{
    class CUSTOMER
    {
        iDAC DAC = DACFactory.GetDAC();
        private long _C_ID = -99;
        private string _C_NAME = "";
        private string _C_EMAIL = "";
        private long _C_PHONE = -99;
        private string _C_UNAME = "";
        private string _C_PASS = "";
        private bool _ISDELETED = false;
        private bool _ISACTIVE = true;
        
        public bool ISDELETED
        {
            get
            {
                return _ISDELETED;
            }
            set
            { 
                _ISDELETED = value;
            }
        }
        public bool ISACTIVE
        {
            get
            {
                return _ISACTIVE;
            }
            set
            {
                _ISACTIVE = value;
            }
        }
       
        public long C_ID
        {
            get
            {
                return _C_ID;
            }
            set
            {
                _C_ID = value;
            }
        }
        public string C_NAME
        {
            get
            {
                return _C_NAME;
            }
            set
            {
                _C_NAME = value;
            }
        }
        public string C_EMAIL
        {
            get
            {
                return _C_EMAIL;
            }
            set
            {
                _C_EMAIL= value;
            }
        }
        public long C_PHONE
        {
            get
            {
                return _C_PHONE;
            }
            set
            {
                _C_PHONE = value;
            }
        }
        
        public string C_UNAME
        {
            get
            {
                return _C_UNAME;
            }
            set
            {
               _C_UNAME = value;
            }
        }
        public string C_PASS
        {
            get
            {
                return C_PASS;
            }
            set
            {
                C_PASS = value;
            }
        }

        public long SaveRecord()
        {
            try
            {
                DbParameter dbparam0 = DAC.Parameter("@C_ID", C_ID, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam1 = DAC.Parameter("@C_NAME",C_NAME, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam2 = DAC.Parameter("@C_EMAIL", C_EMAIL, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam3 = DAC.Parameter("@C_PHONE", C_PHONE, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam4 = DAC.Parameter("@C_UNAME", C_UNAME, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam5 = DAC.Parameter("@C_PASS", C_PASS, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam6 = DAC.Parameter("@ISACTIVE", ISACTIVE, DbType.Boolean, ParameterDirection.Input);
                DbParameter dbparam7 = DAC.Parameter("@ISDELETED", ISDELETED, DbType.Boolean, ParameterDirection.Input);
                DbParameter[] dbparamcall = new DbParameter[] { dbparam0, dbparam1, dbparam2, dbparam3, dbparam4, dbparam5, dbparam6, dbparam7 };
                return DAC.Save("CUSTOMER_SAVE", dbparamcall);
            }
            catch (Exception ex)
            {
                long Result = -99;
            }
            return -99;
        }
        public DataTable GetRecords(long C_ID, string C_NAME, string C_EMAIL, long C_PHONE, string C_UNAME, string C_PASS, bool ISDELETED, bool ISACTIVE, string andor) 
        {
            try
            {
                 DbParameter dbparam0 = DAC.Parameter("@C_ID", C_ID, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam1 = DAC.Parameter("@C_NAME", C_NAME, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam2 = DAC.Parameter("@C_EMAIL", C_EMAIL, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam3 = DAC.Parameter("@C_PHONE", C_PHONE, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam4 = DAC.Parameter("@C_UNAME", C_UNAME, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam5 = DAC.Parameter("@C_PASS", C_PASS, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam6 = DAC.Parameter("@ISACTIVE", ISACTIVE, DbType.Boolean, ParameterDirection.Input);
                DbParameter dbparam7 = DAC.Parameter("@ISDELTED", ISDELETED, DbType.Boolean, ParameterDirection.Input);
                DbParameter dbparam8= DAC.Parameter("@paraandor", andor, DbType.AnsiString, ParameterDirection.Input);
                DbParameter[] dbparamcall = new DbParameter[] { dbparam0, dbparam1, dbparam2, dbparam3, dbparam4, dbparam5, dbparam6, dbparam7,dbparam8};
                DataTable dt = DAC.Select("CUSTOMER_GET", dbparamcall);
                return dt;
            }
            catch (Exception ex)
            {
                long Result = -99;
            }
            return null;
        }

    }
    }

